package com.spark.trouble

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.blankj.utilcode.util.LogUtils
import com.spark.common.BaseActivity
import com.spark.common.helper.Picker
import com.spark.trouble.handle.HTHandleFramgnet

/**
 * 进入隐患处理流程系统
 */
class HTHandleActivity : BaseActivity() {
    private var htHandleFramgnet: HTHandleFramgnet? = null

    companion object {
        fun actionStart(host: Activity, data: String) {
            val intent = Intent(host, HTHandleActivity::class.java)
            intent.putExtra("data", data)
            host.startActivity(intent)
        }
    }

    override fun contentResId(): Int {
        return R.layout.act_container
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        intent?.apply {
            getStringExtra("data")?.apply {
                htHandleFramgnet = HTHandleFramgnet.newInstance(this)
                loadRootFragment(R.id.fl_content, htHandleFramgnet!!)
            }
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        LogUtils.e("【top】${topFragment.javaClass.canonicalName}")
        topFragment.onFragmentResult(requestCode, resultCode, data?.extras)
        htHandleFramgnet?.onFragmentResult(requestCode, resultCode, data?.extras)
        Picker.onActivityResulted(this, requestCode, resultCode, data)
        super.onActivityResult(requestCode, resultCode, data)
    }
}

